<?php

/**
 * Application Models
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 * @copyright ZF model generator
 * @license http://framework.zend.com/license/new-bsd     New BSD License
 */

/**
 * Abstract class for models
 */
require_once 'ModelAbstract.php';

/**
 * 
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 */
class Application_Model_PilotEnregistrement extends Application_Model_ModelAbstract
{

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_IdPILOTENREGISTREMENT;

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_PILOTLOTDATAIdPILOTLOTDATA;


    /**
     * Parent relation fk_PILOT_ENREGISTREMENT_PILOT_LOTDATA1
     *
     * @var Application_Model_PilotLotdata
     */
    protected $_PilotLotdata;


    /**
     * Dependent relation fk_PILOT_DATAELEMENT_PILOT_ENREGISTREMENT1
     * Type: One-to-Many relationship
     *
     * @var Application_Model_PilotDataelement
     */
    protected $_PilotDataelement;

    /**
     * Sets up column and relationship lists
     */
    public function __construct()
    {
        parent::init();
        $this->setColumnsList(array(
            'idPILOT_ENREGISTREMENT'=>'IdPILOTENREGISTREMENT',
            'PILOT_LOTDATA_idPILOT_LOTDATA'=>'PILOTLOTDATAIdPILOTLOTDATA',
        ));

        $this->setParentList(array(
            'FkPILOTENREGISTREMENTPILOTLOTDATA1'=> array(
                    'property' => 'PilotLotdata',
                    'table_name' => 'PilotLotdata',
                ),
        ));

        $this->setDependentList(array(
            'FkPILOTDATAELEMENTPILOTENREGISTREMENT1' => array(
                    'property' => 'PilotDataelement',
                    'table_name' => 'PilotDataelement',
                ),
        ));
    }

    /**
     * Sets column idPILOT_ENREGISTREMENT
     *
     * @param int $data
     * @return Application_Model_PilotEnregistrement
     */
    public function setIdPILOTENREGISTREMENT($data)
    {
        $this->_IdPILOTENREGISTREMENT = $data;
        return $this;
    }

    /**
     * Gets column idPILOT_ENREGISTREMENT
     *
     * @return int
     */
    public function getIdPILOTENREGISTREMENT()
    {
        return $this->_IdPILOTENREGISTREMENT;
    }

    /**
     * Sets column PILOT_LOTDATA_idPILOT_LOTDATA
     *
     * @param int $data
     * @return Application_Model_PilotEnregistrement
     */
    public function setPILOTLOTDATAIdPILOTLOTDATA($data)
    {
        $this->_PILOTLOTDATAIdPILOTLOTDATA = $data;
        return $this;
    }

    /**
     * Gets column PILOT_LOTDATA_idPILOT_LOTDATA
     *
     * @return int
     */
    public function getPILOTLOTDATAIdPILOTLOTDATA()
    {
        return $this->_PILOTLOTDATAIdPILOTLOTDATA;
    }

    /**
     * Sets parent relation PILOTLOTDATAIdPILOTLOTDATA
     *
     * @param Application_Model_PilotLotdata $data
     * @return Application_Model_PilotEnregistrement
     */
    public function setPilotLotdata(Application_Model_PilotLotdata $data)
    {
        $this->_PilotLotdata = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['idPILOT_LOTDATA'];
        }

        $this->setPILOTLOTDATAIdPILOTLOTDATA($primary_key);

        return $this;
    }

    /**
     * Gets parent PILOTLOTDATAIdPILOTLOTDATA
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_PilotLotdata
     */
    public function getPilotLotdata($load = true)
    {
        if ($this->_PilotLotdata === null && $load) {
            $this->getMapper()->loadRelated('FkPILOTENREGISTREMENTPILOTLOTDATA1', $this);
        }

        return $this->_PilotLotdata;
    }

    /**
     * Sets dependent relations fk_PILOT_DATAELEMENT_PILOT_ENREGISTREMENT1
     *
     * @param array $data An array of Application_Model_PilotDataelement
     * @return Application_Model_PilotEnregistrement
     */
    public function setPilotDataelement(array $data)
    {
        $this->_PilotDataelement = array();

        foreach ($data as $object) {
            $this->addPilotDataelement($object);
        }

        return $this;
    }

    /**
     * Sets dependent relations fk_PILOT_DATAELEMENT_PILOT_ENREGISTREMENT1
     *
     * @param Application_Model_PilotDataelement $data
     * @return Application_Model_PilotEnregistrement
     */
    public function addPilotDataelement(Application_Model_PilotDataelement $data)
    {
        $this->_PilotDataelement[] = $data;
        return $this;
    }

    /**
     * Gets dependent fk_PILOT_DATAELEMENT_PILOT_ENREGISTREMENT1
     *
     * @param boolean $load Load the object if it is not already
     * @return array The array of Application_Model_PilotDataelement
     */
    public function getPilotDataelement($load = true)
    {
        if ($this->_PilotDataelement === null && $load) {
            $this->getMapper()->loadRelated('FkPILOTDATAELEMENTPILOTENREGISTREMENT1', $this);
        }

        return $this->_PilotDataelement;
    }

    /**
     * Returns the mapper class for this model
     *
     * @return Application_Model_Mapper_PilotEnregistrement
     */
    public function getMapper()
    {
        if ($this->_mapper === null) {
            $this->setMapper(new Application_Model_Mapper_PilotEnregistrement());
        }

        return $this->_mapper;
    }

    /**
     * Deletes current row by deleting the row that matches the primary key
     *
	 * @see Application_Model_Mapper_PilotEnregistrement::delete
     * @return int|boolean Number of rows deleted or boolean if doing soft delete
     */
    public function deleteRowByPrimaryKey()
    {
        if ($this->getIdPILOTENREGISTREMENT() === null) {
            throw new Exception('Primary Key does not contain a value');
        }

        return $this->getMapper()
                    ->getDbTable()
                    ->delete('idPILOT_ENREGISTREMENT = ' .
                             $this->getMapper()
                                  ->getDbTable()
                                  ->getAdapter()
                                  ->quote($this->getIdPILOTENREGISTREMENT()));
    }
}
